import ObservableObject from "../observer/observable.object"
import { BitmapFontPacker, BitmapFontPackerStatic } from "../three/Label3D"
const fontData = {
  pages: [],
  chars: [],
  info: {
    face: "Loading",
    size: 0,
    bold: 0,
    italic: 0,
    charset: [],
    unicode: 1,
    stretchH: 100,
    smooth: 1,
    aa: 1,
    padding: [0, 0, 0, 0],
    spacing: [0, 0],
    os2version: 1
  },
  common: {
    lineHeight: 0,
    base: 0,
    scaleW: 1,
    scaleH: 1,
    pages: 0,
    packed: 0,
    alphaChnl: 0,
    redChnl: 0,
    greenChnl: 0,
    blueChnl: 0
  },
  kernings: []
}
export default class BitmapFontAtlas extends ObservableObject {
  packer: BitmapFontPackerStatic | BitmapFontPacker
  fontData: typeof fontData
  textures: any[]
  constructor(e: BitmapFontPackerStatic | BitmapFontPacker) {
    super()
    this.packer = e
    this.fontData = fontData
    this.textures = []
  }
  update(e, t) {
    this.fontData = t
    this.textures.forEach(e => e.dispose())
    this.textures.length = 0
    this.textures.push(...e)
    this.commit()
  }
  addCharsIfNeeded(e) {
    this.packer.addChars(e)
  }
}
